package org.ramoths.netcom.outils;

import java.io.IOException;
import java.io.InputStream;

public class FluxEntreeObjet extends InputStream
{
	private final byte[] donnees;
	private int indexe;
	
	public FluxEntreeObjet(byte[] donnees)
	{
		this.donnees = donnees;
		this.indexe = 0;
	}
	
	@Override
	public int read() throws IOException
	{
		if (indexe == donnees.length)
			return -1;
		return getByte(donnees[indexe++]);
	}
	
	private static int getByte(byte b)
	{
		if (b >= 0)
			return b;
		else
			return 256 + b;
	}
}
